import Vue from 'vue'
import VueRouter from "vue-router"

import Layout from '@/views/Layout'
import ArticleDetail from '@/views/ArticleDetail'
import Article from '@/views/Article'
import Collect from '@/views/Collect'
import Like from '@/views/Like'
import User from '@/views/User'


Vue.use(VueRouter)



const router = new VueRouter({
  mode: 'history',
  routes: [
    { 
      path: '/', 
      component: Layout,
      redirect: '/article',
      // 通过 children 配置项，可以配置嵌套子路由
      // 1. 在children配置项中，配规则
      // 2. 准备二级路由出口
      children: [
        { path: '/article', component: Article},    
        { path: '/collect', component: Collect},    
        { path: '/like', component: Like},    
        { path: '/user', component: User},    
      ]
    },
    { 
      //参数传参方式
      //path: '/detail', component: ArticleDetail

      //动态路由传参方式 step-1
      path: '/detail/:id', component: ArticleDetail
    },

  ]
})

export default router